package cn.edu.cug.cs.gtl.docsrv.dict.controller;

import cn.edu.cug.cs.gtl.docsrv.dict.exception.BaseException;
import cn.edu.cug.cs.gtl.docsrv.dict.service.DictCatalogService;
import cn.edu.cug.cs.gtl.docsrv.dict.service.DictDataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@CrossOrigin
@RequestMapping("/api/dict/datasource")
public class DictDataSourceContoller {
    @Autowired
    DictDataSourceService dictDataSourceService;
    //获取所有数据源信息
    @GetMapping(value = "/getDataSources")
    public Object getDataSources() {
        try {
            return dictDataSourceService.getDataSources();
        } catch (Exception e) {
            throw new BaseException(e.getMessage());
        }
    }

    //获取所有数据源信息
    @GetMapping(value = "/getDataSourceNames")
    public Object getDataSourceNames() {
        try {
            return dictDataSourceService.getDataSourceNames();
        } catch (Exception e) {
            throw new BaseException(e.getMessage());
        }
    }
}
